<?php

// content="text/plain; charset=utf-8"//注意 用Jpgraph 现有代码内 不能打印多余空格 
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');

$id = $_GET["id"];
/**
 * 这里数据可以从数据库获取
 */
switch ($id) {
    case 1:
        $datay1 = array(13, 8, 19, 7, 17, 6);
        $datay2 = array(4, 5, 2, 7, 5, 25);
        break;
    case 2:
        $datay1 = array(12, 3, 199, 7, 178, 6);
        $datay2 = array(43, 5, 2, 72, 5, 205);
        break;
}


// Create the graph.
$graph = new Graph(350, 250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
/**
 * 设置中文这块太贱了 只能这么设置才起作用。。。
 */
// Setup title
switch ($id) {
    case 1:
        $graph->title->Set(iconv("UTF-8", "GB2312//IGNORE", "支持狄仁杰胜率")); //设置报表标题
        break;
    case 2:
        $graph->title->Set(iconv("UTF-8", "GB2312//IGNORE", "支持鲁班胜率")); //设置报表标题
        break;
}
//$graph->title->Set(iconv("UTF-8", "GB2312//IGNORE", "支持狄仁杰胜率")); //设置报表标题
$graph->title->SetFont(FF_SIMSUN, FS_BOLD, 14); // 设置中文字体
// Create the first bar
$bplot = new BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2', 'AntiqueWhite4:0.8', GRAD_VERT);
$bplot->SetColor('darkred');

// Create the second bar
$bplot2 = new BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT);
$bplot2->SetColor('darkgreen');

// And join them in an accumulated bar
$accbplot = new AccBarPlot(array($bplot, $bplot2));
$graph->Add($accbplot);

$graph->Stroke();
?>
